import { fromJS } from 'immutable'
import { FILMTYPE_ADDFILMS } from '@/store/types/filmType'

const initState = fromJS({
  films: []
})

/* const methods = {
  addFilms(state, data) {
    return state.set('films', data)
  }
} */

const methods = {
  // 变量的值当作方法名称
  [FILMTYPE_ADDFILMS](state, data) {
    return state.set('films', data)
  }
}

export default (state = initState, { type, data }) => {
  try {
    return methods[type](state, data)
  } catch (error) {
    return state
  }
}
